package com.wonghiu.framework.cluster.loadbalance.loadbalancer;

import com.wonghiu.framework.cluster.loadbalance.AbstractLoadBalance;
import com.wonghiu.framework.exchange.HRpcRequest;

import java.util.List;
import java.util.Random;

/**
 * @Author wonghiu
 * @Date 2021/8/10 20:21
 * @Version 1.0.1
 */
public class RandomLoadBalance extends AbstractLoadBalance {
    @Override
    protected String doSelect(List<String> serviceAddresses, HRpcRequest rpcRequest) {
        Random random = new Random();
        return serviceAddresses.get(random.nextInt(serviceAddresses.size()));
    }
}
